<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>反转字符串</title>
</head>

<body>
    <script>
        var str = prompt("请输入想要想要反转的文字");
        var rts = "";
        for (var i = 0; i <= str.length; i++) {
            rts += str.substring(str.length - i, str.length - i - 1);
        }
        document.write(rts);
        // alert(str.substring(1, 2));
    </script>

</body>

</html>